<?cs if:config.notify_daemon ?>
<script language="javascript" src="<?cs var:config.docpath?>js/dmt_xrkmonitor.js"></script>
<?cs /if ?>

<?cs if:config.xrkmonitor_debug==1 ?>
<script src="<?cs var:config.docpath?>resource/js/dmt.comm.js?v=850" type="text/javascript"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.js"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.cookie.js"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.validate.js"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.bgiframe.js"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.highlight-3.js"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.easing.1.3.js?v=1"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.json-2.3.js?v=1"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.md5.js?v=1"></script>
<script src="<?cs var:config.docpath?>resource/js/dwz.min.js?v=20200826"></script>
<script src="<?cs var:config.docpath?>resource/js/dwz.regional.zh.js?v=7999"></script>
<script src="<?cs var:config.docpath?>resource/js/echarts.min.js"></script>
<script src="<?cs var:config.docpath?>resource/js/china.js"></script>
<?cs else ?>
<script src="<?cs var:config.docpath?>resource/js/dmt.comm.min.js?v=111110708" type="text/javascript"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.min.js?v=2020506"></script>
<script src="<?cs var:config.docpath?>resource/js/jquery.other.min.js?v=2020506"></script>
<script src="<?cs var:config.docpath?>resource/js/dwz.all.min.js?v=20200826"></script>
<script src="<?cs var:config.docpath?>resource/js/echarts.min.js?v=2020506"></script>
<script src="<?cs var:config.docpath?>resource/js/china.min.js?v=2020506"></script>
<?cs /if ?>

<script type="text/javascript">

var g_di_cspath = '<?cs var:config.cspath ?>';
var g_di_docpath = '<?cs var:config.docpath ?>';
var g_di_cgipath = '<?cs var:config.cgipath?>';

/* localStorage 浏览器兼容问题 fix */
if (!window.localStorage) {
  window.localStorage = {
    getItem: function (sKey) {
      if (!sKey || !this.hasOwnProperty(sKey)) { return null; }
      return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" 
		+ escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
    },
    key: function (nKeyId) {
      return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/, "").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]);
    },
    setItem: function (sKey, sValue) {
      if(!sKey) { return; }
      document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";
      this.length = document.cookie.match(/\=/g).length;
    },
    length: 0,
    removeItem: function (sKey) {
      if (!sKey || !this.hasOwnProperty(sKey)) { return; }
      document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
      this.length--;
    },
    hasOwnProperty: function (sKey) {
      return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
    }
  };
  window.localStorage.length = (document.cookie.match(/\=/g) || window.localStorage).length;
}

function djOnReadyOk()
{
	// 主页相关逻辑
	dcOnMainPage();
	dcInitMainPage();
	dcRefreshStatInfo();
	setTimeout(function(){ $('#navMenuLast a').click(); }, 100);
}

function djCheckLoginType() 
{ 
	var support_var_css = false;
	try {
		document.documentElement.className = "js";
		var supportsCssVars = function() { 
			var e, t = document.createElement("style"); 
			return t.innerHTML = "root: { --tmp-var: bold; }", 
			   document.head.appendChild(t), e = !!(window.CSS && window.CSS.supports 
				   && window.CSS.supports("font-weight", "var(--tmp-var)")), t.parentNode.removeChild(t), e
		};
		if(supportsCssVars())
			support_var_css = true;
	}catch(e) {
	}

	if(support_var_css)
		return 'var_css';
	return 'old'
}


$(document).ready(function(){
	DWZ.init("<?cs var:config.docpath?>resource/dwz.frag.html", {
		statusCode:{ok:200, error:300, timeout:301}, //【可选】
		pageInfo:{pageNum:"pageNum", numPerPage:"numPerPage", orderField:"orderField", orderDirection:"orderDirection"}, //【可选】
		debug:false,	// 调试模式 【true|false】
		callback:function(){
			initEnv();

			// global info for javascript use
			g_siteInfo = $.parseJSON('<?cs var:config.site_info ?>');
			$("#themeList").theme({themeBase:"<?cs var:config.docpath?>resource/themes", defaultTheme:"toptry"});

			$("#a_logout").click(function(){
				var d = new Date();
				var url = g_siteInfo.cgi_path+"slog_flogin?action=logout&v="+d.getTime()+'&login_show='+djCheckLoginType();
				location.replace(url);
				return false;
			});

			$("#a_relogin").click(function(){
				var url = g_siteInfo.cgi_path+"slog_flogin?action=relogin&redirect_url=";
				url += encodeURIComponent(window.location);
				url += "&user_id=<?cs var:comm.user_id ?>";
				location.replace(url);
				return false;
			});

			if(<?cs var:config.check_lv2_vcode ?>+0 == 1) {
				djLv2CheckPopDlg();
				return ;
			}

			djOnReadyOk();

			$('#dc_btn_main_full').click(function() { 
				var f = dmtToggleFullScreen(document.documentElement);
				if(f == 'error')
					alertMsg.info('暂不支持您的浏览器进入全屏<br> (建议使用 Chrome 或者 Firefox 浏览器)');
				else if(f == 'yes') {
					$('#dc_btn_main_full').html("<i class='icon-resize-small icon-2x'></i>退出全屏");   
					navTab._closeOtherTab();
					setTimeout(function() {navTab.reload(); }, 1000);
				}
				else {
					$('#dc_btn_main_full').html("<i class='icon-resize-full icon-2x'></i>进入全屏");    
					navTab._closeOtherTab();
					setTimeout(function() {navTab.reload(); }, 1000);
				}
			});
		}
	});
});

</script>

